package cn.sunlelin.educationserver.controller;

import cn.sunlelin.educationserver.param.LoginParam;
import cn.sunlelin.educationserver.service.CommonService;
import cn.sunlelin.educationserver.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class CommonController {

    @Autowired
    private CommonService commonService;

    // 权限码请求接口
    @PostMapping("/code/request")
    public R getRequestPermissionCode(@RequestBody String emailJson) {
        return commonService.getRequestPermissionCode(emailJson);
    }

    // 邮箱验证码接口
    @PostMapping("/code/email")
    public R sendEmailCode(@RequestBody LoginParam loginParam) {
        System.out.println(loginParam.getEmail());
        return commonService.sendEmailCode(loginParam);
    }
}
